var Mock = require('mock')
var  obj  = {
  'GET /api/getlunbo': {
      username: 'admin',
      sex: 5,
  },
  'GET /dev/api/getlunbo': function (req, res) {
      let query = req.query || {};
      return res.json({
          limit: query.limit,
          offset: query.offset,
          list: [{
              username: 'admin1',
              sex: 1,
          }, {
              username: 'admin2',
              sex: 6,
          }]
      })
  },
  'GET /api/userinfo/:id': (req, res) => {
      return res.json({
          id: req.params.id,
          username: 'kenny',
      });
  },
  'POST /api/login/account': (req, res) => {
      const { password, username } = req.body;
      if (password === '888888' && username === 'admin') {
          return res.json({
              status: 'ok',
              token: 'sdfsdfsdfdsf',
          });
      } else {
          return res.json({
              status: 'error',
              code: 403,
          });
      }
  },
  'DELETE /api/user/:id': (req, res) => {
      // console.log(req.params.id);
      res.send({ status: 'ok', message: 'delete success!' });
  },
  'PUT /api/user/:id': (req, res) => {
      // console.log(req.params.id);
      // console.log(req.body);
      res.send({ status: 'ok', message: 'update success！' });
  },
}




module.exports = ({ app }) => {
  app.get('/api/getlunbo', (req, res) => {
    console.log(123);
    res.json(Mock.mock({
      // 属性 list 的值是一个数组，其中含有 1 到 10 个元素
      'list|1-10': [{
          // 属性 id 是一个自增数，起始值为 1，每次增 1
          'id|+1': 1
      }]
  }))
  })
  app.get('/dev/api/getlunbo', (req, res) => {
    console.log(123);
    res.json({
          code:2000,
          msg:"请求成功",
          data: [ 
              {  img:"https://img2.baidu.com/it/u=564143470,20272037&fm=253&fmt=auto&app=138&f=JPEG?w=574&h=500"   },
              {  img:"https://img2.baidu.com/it/u=3215730428,3406193656&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1665939600&t=d3a6819855c178b66a4aab555ea10700"   }
             , {  img:"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fziti.cndesign.com%2Fupload%2Ffont%2F2017-01-10%2Fcd20a70a75664fc8ae40d64598f117c1.jpg&refer=http%3A%2F%2Fziti.cndesign.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1668414149&t=c828ad820ccd7811ca7a392cea16da31"   }

          ] 
    })
  })


}


/*  
    {   
        "/dev/api/getlunbo2":{   
              methods: "post"
                callback: ()=>{
                }
        },
        "/dev/api/getlunbo3":{  
             methods: "post"
                callback: ()=>{
                }
        }

    }



    `[         

      {   methods:"post", url:"" ,  callbalck()=>{

      }       }


         ]


*/
